<template>
  <div class="radar">
    <!-- 雷达图 -->
    <div ref="mybox" class="box" />
  </div>
</template>

<script>
// 按需加载
import * as echarts from "echarts/core"; // 引入主模块
import { RadarChart } from "echarts/charts"; // 引入雷达图
// 引入提示框和标题组件
import {
  TitleComponent,
  TooltipComponent,
  LegendComponent
} from "echarts/components";
// 引入canvas渲染器
import { CanvasRenderer } from "echarts/renderers";
// 注册必须的组件
echarts.use([
  TitleComponent,
  TooltipComponent,
  LegendComponent,
  RadarChart,
  CanvasRenderer,
]);
export default {
  mounted() {
    // 基于准备好的dom，初始化echarts实例
    const myChart = echarts.init(this.$refs.mybox);
    // 绘制图表
    myChart.setOption({
      // 标题
      title: {
        text: "个人水平图",
      },
      // 图例
      legend: {
        data: ["个人水平", "平均水平"],
        right: 0,
        orient: "vertical",
      },
      radar: {
        // shape: 'circle',
        indicator: [
          { name: "工作效率", max: 100 },
          { name: "考勤", max: 100 },
          { name: "积极性", max: 100 },
          { name: "帮助同事", max: 100 },
          { name: "自主学习", max: 100 },
          { name: "正确率", max: 100 },
        ],
      },
      series: [
        {
          name: "个人 vs 平均",
          type: "radar",
          data: [
            {
              value: [100, 100, 100, 100, 100, 100],
              name: "个人水平",
            },
            {
              value: [90, 70, 80, 60, 75, 90],
              name: "平均水平",
            },
          ],
        },
      ],
    });
  },
};
</script>

<style lang="scss" scoped>
.radar {
  .box {
    width: 500px;
    height: 400px;
    // background-color: #8df;
  }
}
</style>